/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package slcu.model;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.BaseModel;
import com.liferay.portal.model.impl.BaseModelImpl;

import slcu.service.ConfiguracionLocalServiceUtil;

import java.io.Serializable;

import java.lang.reflect.Proxy;

import java.util.HashMap;
import java.util.Map;

/**
 * @author tito
 */
public class ConfiguracionClp extends BaseModelImpl<Configuracion>
	implements Configuracion {
	public ConfiguracionClp() {
	}

	public Class<?> getModelClass() {
		return Configuracion.class;
	}

	public String getModelClassName() {
		return Configuracion.class.getName();
	}

	public String getPrimaryKey() {
		return _name;
	}

	public void setPrimaryKey(String primaryKey) {
		setName(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return _name;
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey((String)primaryKeyObj);
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("name", getName());
		attributes.put("value", getValue());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		String name = (String)attributes.get("name");

		if (name != null) {
			setName(name);
		}

		String value = (String)attributes.get("value");

		if (value != null) {
			setValue(value);
		}
	}

	public String getName() {
		return _name;
	}

	public void setName(String name) {
		_name = name;
	}

	public String getValue() {
		return _value;
	}

	public void setValue(String value) {
		_value = value;
	}

	public BaseModel<?> getConfiguracionRemoteModel() {
		return _configuracionRemoteModel;
	}

	public void setConfiguracionRemoteModel(
		BaseModel<?> configuracionRemoteModel) {
		_configuracionRemoteModel = configuracionRemoteModel;
	}

	public void persist() throws SystemException {
		if (this.isNew()) {
			ConfiguracionLocalServiceUtil.addConfiguracion(this);
		}
		else {
			ConfiguracionLocalServiceUtil.updateConfiguracion(this);
		}
	}

	@Override
	public Configuracion toEscapedModel() {
		return (Configuracion)Proxy.newProxyInstance(Configuracion.class.getClassLoader(),
			new Class[] { Configuracion.class }, new AutoEscapeBeanHandler(this));
	}

	@Override
	public Object clone() {
		ConfiguracionClp clone = new ConfiguracionClp();

		clone.setName(getName());
		clone.setValue(getValue());

		return clone;
	}

	public int compareTo(Configuracion configuracion) {
		String primaryKey = configuracion.getPrimaryKey();

		return getPrimaryKey().compareTo(primaryKey);
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		ConfiguracionClp configuracion = null;

		try {
			configuracion = (ConfiguracionClp)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		String primaryKey = configuracion.getPrimaryKey();

		if (getPrimaryKey().equals(primaryKey)) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return getPrimaryKey().hashCode();
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(5);

		sb.append("{name=");
		sb.append(getName());
		sb.append(", value=");
		sb.append(getValue());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(10);

		sb.append("<model><model-name>");
		sb.append("slcu.model.Configuracion");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>name</column-name><column-value><![CDATA[");
		sb.append(getName());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>value</column-name><column-value><![CDATA[");
		sb.append(getValue());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private String _name;
	private String _value;
	private BaseModel<?> _configuracionRemoteModel;
}